print("欢迎来到ShoopingV1.0系统！")
print("请选择您要进行的操作：")
print("1.购买商品")
tatal_money = 100
temp_money = tatal_money
print("您的账户余额为：", tatal_money)
goods_price = 0
tatal_goods_price = 0
print("-----------------------------------------------------------------")
choice = int(input("请输入您的选择："))
goods_list = ["苹果", "香蕉", "橘子", "草莓", "葡萄", "柠檬"]
my_goods_list = []
print("我的购物列表：", my_goods_list)
print("商品列表：", goods_list)

def ShoopingV1():
    global goods_price
    global tatal_goods_price
    global tatal_money
    global temp_money
    while choice == 1 and tatal_money > 0 :
        goods_name = input("请输入您要购买的商品名称：")
        if goods_name in goods_list:
            if goods_name == "苹果":
                my_goods_list.append("苹果")
                goods_price = 50
                tatal_goods_price += goods_price
            elif goods_name == "香蕉":
                my_goods_list.append("香蕉")
                goods_price = 30
                tatal_goods_price += goods_price
            elif goods_name == "橘子":
                my_goods_list.append("橘子")
                goods_price = 40
                tatal_goods_price += goods_price
            elif goods_name == "草莓":
                my_goods_list.append("草莓")
                goods_price = 20
                tatal_goods_price += goods_price
            elif goods_name == "葡萄":
                my_goods_list.append("葡萄")
                goods_price = 35
                tatal_goods_price += goods_price
            elif goods_name == "柠檬":
                my_goods_list.append("柠檬")
                goods_price = 25
                tatal_goods_price += goods_price
            else:
                print("您输入的商品名称不存在，请重新输入！")
            if  tatal_money >= goods_price:
                tatal_money -= goods_price
                print("您已成功购买", goods_name, "，您的账户余额为：", tatal_money)
                print("======================================")
                print("若要退出购物请输入：q,继续购物请回车或任意字符！")
                if input() == "q":
                    break
                else:
                    continue
            else:
                tatal_money = temp_money
                print("======================================")
                print("您的账户余额不足，请充值后再试！")
                print("由于您未能成功购买商品，系统已退出！")
                break
        else:
            print("======================================")
            print("您输入的商品名称不存在，请重新输入！")


    print("你的购物小票为", my_goods_list, "，总价为", tatal_goods_price, "元。")
    print("余额为：", tatal_money, "元。")
    print("欢迎下次使用ShoopingV1.0系统！")
    print("-----------------------------------------------------------------------")
ShoopingV1()

